package vlms.dao;

import java.sql.*;

import vlms.exception.PremiumcustomerRecordCountException;

public class PremiumcustomerRecordCountDAO {
	public PremiumcustomerRecordCountDAO() {
	}

	public PremiumcustomerRecordCount getRecordCount(Connection con)
			throws PremiumcustomerRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con.prepareStatement("SELECT COUNT(*) FROM PREMIUMCUSTOMER");
			rs = stmt.executeQuery();
			rs.next();
			PremiumcustomerRecordCount vo = new PremiumcustomerRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new PremiumcustomerRecordCountException(sqle);
		} catch (Exception e) {
			throw new PremiumcustomerRecordCountException(e);
		}
	}

	public PremiumcustomerRecordCount getRecordCount(Connection con,
			String whereClause) throws PremiumcustomerRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con
					.prepareStatement("SELECT COUNT(*) FROM PREMIUMCUSTOMER  "
							+ whereClause);
			rs = stmt.executeQuery();
			rs.next();
			PremiumcustomerRecordCount vo = new PremiumcustomerRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new PremiumcustomerRecordCountException(sqle);
		} catch (Exception e) {
			throw new PremiumcustomerRecordCountException(e);
		}
	}
}
